#ifndef COBJECT_H
#define COBJECT_H


#include "AObject.h"

class CObject : public QObject
{
    Q_OBJECT
public:
    CObject()
    {
        AObject *AObj = new AObject();

        AObj->moveToThread(&thread);

        connect(&thread, &QThread::finished, AObj, &QObject::deleteLater);

        connect(this, &CObject::operate, AObj, &AObject::slot);

        connect(AObj, &AObject::sig, this, &CObject::slot);

        thread.start();
    }

    ~CObject()
    {
        thread.quit();
        thread.wait();
    }

signals:
      void operate(const QString &s);

public slots:
      void slot(const QString &s)
      {
          qDebug() << "CObjcet slot from thread :" << QThread::currentThreadId() << s;
      }

private:
    QThread thread;
};
#endif
